/**
 * ...
 * >author		João Vítor de Souza
 */

package com.cupcakeengine.utils 
{

	public class NumberUtil 
	{
		// ___________________________________________________________________ CONSTANTS		
		
		// ___________________________________________________________________ CLASS PROPERTIES
		
		// ___________________________________________________________________ INSTANCE PROPERTIES
		
		// ___________________________________________________________________ GETTERS AND SETTERS
		
		// ___________________________________________________________________ CONSTRUCTOR
		
		// ___________________________________________________________________ PUBLIC METHODS
		
		static public function round(s:String):String
		{
			if (s.length < 4) return s;
			
			var max:int = int((s.length - 1)/ 3);			
			var r:String = "";
			
			for (var i:int = 1; i <= max; i++) {
				r = "," + s.substring(s.length - (3 * i), s.length - (3 * (i - 1))) + r;				
			}			
			
			r = s.substring(0, s.length - (max * 3)) + r;
			
			return r;
		}
		
		// ___________________________________________________________________ PRIVATE METHODS
		
		// ___________________________________________________________________ EVENTS
	}
}

